// 将在全局初始化一个 mqtt 变量
    // 连接选项
	const options = {
		connectTimeout: 4000, // 超时时间
		// 认证信息
		clientId: 'emqx-1',
		username: 'admin',
		password: 'hrc*20200915',
	}
	const client = mqtt.connect('ws://39.97.173.164:8083/mqtt', options)

	// client.on('reconnect', (error) => {
	// 	console.log('正在重连:', error)
	// })

	client.on('error', (error) => {
		console.log('连接失败:', error)
	})
	// 正确示例

	client.on('connect', (e) => {
		
	})
	client.subscribe('/topic/put', { qos: 0 }, (error) => {
		
	})
	
	client.on('message', function(topic, message){
		var data = message.toString();
		data = JSON.parse(data);
		var imei = document.getElementById('imei').innerText;
		if(data.IMEI == imei){
			document.getElementById('signal').innerText = data.Signal;
			document.getElementById('tem').innerText = data.Tem;
		}
	})

	client.publish('testtopic', 'Hello EMQ1111111', { qos: 1, rein: false }, (error) => {
		//cosnole.log(error || '发布成功')
	})
